package com.harlan.viewbindingstudy.kotlin

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.harlan.viewbindingstudy.databinding.KotlinItemBinding

class KotlinAdapter : RecyclerView.Adapter<KotlinAdapter.viewHold> {
    var context: Context? = null
    lateinit var binding: KotlinItemBinding

    constructor(context: Context) {
        this.context = context
    }

    class viewHold(view: View) : RecyclerView.ViewHolder(view) {

    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): viewHold {
        binding = KotlinItemBinding.inflate(LayoutInflater.from(context), parent, false)
        return viewHold(binding.root)
    }

    override fun onBindViewHolder(holder: viewHold, position: Int) {
        binding.kotlinUse.text = "第" + position + "项"
    }

    override fun getItemCount(): Int {
        return 8
    }
}